package interfaceExample;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class MouseListenerExample extends JPanel {
	public static void main(String args[]){
		MouseListenerExample mse = new MouseListenerExample();
		
		JFrame frame = new JFrame("MouseListenr");
		frame.getContentPane().add(mse);
		frame.setVisible(true);
		frame.setSize(800, 800);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	
	public MouseListenerExample(){
		this.addMouseListener(new MouseFag());
	}
	
	class MouseFag implements MouseListener {
		public void mouseClicked(MouseEvent arg0) {
			System.out.println(arg0.getX() + " " + arg0.getY()); //simply print out x and y coords of the mouse click
		}


		public void mouseEntered(MouseEvent arg0) { }
		public void mouseExited(MouseEvent arg0) { }
		public void mousePressed(MouseEvent arg0) { }
		public void mouseReleased(MouseEvent arg0) { }
	}

}
//so first thing you should notice, is taht MouseListener requirs you to implement 5 functions isntead of jsut one

//yo? yoyo run it and click on the screen and watch the console as it prints out coords
//works?nice
//now, look at this, here we tell MouseFag to deal with the new action, but there are several ways of solving this
//for example we could let our main class implement it (made new class)

//the top part, the lines 10-14 is pretty standard for gui dev, like every java gui has those,
//its just to set window size, visible and frame name and add the actual panel to the said frame